﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class BrightnessSaturationContrast : PostEffectsBase {

    public Shader shader;
    private Material mat;
    public Material material
    {
        get
        {
            mat = CheckShaderAndCreateMaterial(shader, mat);
            return mat;
        }
    }

    [Range(0.0f, 3.0f)]
    public float Brightness;
    [Range(0.0f, 3.0f)]
    public float Saturation;
    [Range(0.0f, 3.0f)]
    public float Contrast;

    private void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        if (material)
        {
            material.SetFloat("_Brightness", Brightness);
            material.SetFloat("_Saturation", Saturation);
            material.SetFloat("_Contrast", Contrast);
            Graphics.Blit(source, destination, material);
        }
        else
        {
            Graphics.Blit(source, destination);
        }
    }
}
